import { Timer } from 'babylon-lib/misc/timer';
import * as Data from '../../data/data';
import { Sound } from '@babylonjs/core/Audio/sound';
import { CONTROLLER_TIP_MODE, CONTROLLER_TIP_TYPE, ControllerTip } from 'babylon-lib/xr/xr-input/controller-tip';
import { FreezeCamera } from 'babylon-lib/misc/freeze-camera';
import { NotePanel } from '../../ui/note-panel';


class ProgressManager {

    private static _initialized = false;
    private static _started = false;

    public static reset(): void {
        Timer.pause = true;
        this._started = false;

        for (const key in Data.sounds) {
            const s = (Data.sounds as any)[key] as Sound;
            if (s) s.stop();
        }
        ControllerTip.disable();
    }

    public static start(): void {
        Timer.intervalInSeconds = 1;
        Timer.start();
        Timer.pause = false;
        if (!this._initialized) {
            this.initialize();
            this._initialized = true;
        }
        this._started = true;
    }

    public static set pause(pause: boolean) {
        Timer.pause = pause;
    }

    public static get started(): boolean {
        return this._started;
    }

    private static initialize(): void {

        Timer.addDurationHandle(0, () => {
            FreezeCamera.unfreeze();
            // Data.controlPanelDisplay.value = true;
        });

        Timer.addDurationHandle(2, () => {
            ControllerTip.enable(CONTROLLER_TIP_MODE.LONG, CONTROLLER_TIP_TYPE.THUMBSTICK);
            NotePanel.note(20,'可移动到不同位置观察模型。');
        });
    }

}


export { ProgressManager };